package com.itheima.health.security.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("test")
@Slf4j
public class TestController {

    @PreAuthorize("hasAnyAuthority('add','ROLE_ADMIN')")
    @RequestMapping("addData")
    public String addData() {
        return "add ok";
    }

    @PreAuthorize("hasAuthority('update')")
    @RequestMapping("updateData")
    public String updateData() {
        return "update ok";
    }

    @PreAuthorize("hasAuthority('delete')")
    @RequestMapping("delData")
    public String delData() {
        return "delete ok";
    }

    @PreAuthorize("hasAuthority('find')")
    @RequestMapping("findData")
    public String findData() {
        return "find ok";
    }
}
